
<?php
$date_st = $_POST['dateupdate'];
$date_st = substr($date_st,6,4)."-".substr($date_st,3,2)."-".substr($date_st,0,2);
$date_st = $date_st." ".$_POST['dateupdate2'];
echo $date_st;
$dateupdate = $date_st;
//$idtool = $_POST['idtool'];
$j=0;
for($i=0;$i<count($_POST["idtool"]);$i++)
{
	if(trim($_POST["idtool"][$i]) != "")
	{
		echo "chkColor $i = ".$_POST["idtool"][$i]."<br>";
		$txt[$j]=$_POST["idtool"][$i];
		$j++;
	}
}
$con = mysql_connect('localhost', 'root', '');
if (!$con) {
	die('Could not connect: '.mysql_error());
}

mysql_select_db("aris", $con);
mysql_query("SET NAMES UTF8");
for ($i=0;$i<count($txt);$i++)
{
$sql = "UPDATE  `aris`.`result` SET  `dateEnd` =  '$dateupdate' 
WHERE  `result`.`idTool` =  '$txt[$i]' AND `result`.`dateEnd` =  '0000-00-00 00:00:00' ;";
$sqlAdd4 = "UPDATE `machine` SET `status`=0 WHERE `id`=".$txt[$i];//แก้สถานะเครื่อง

echo $sql;
$result = mysql_query($sql);
$result = mysql_query($sqlAdd4);
}


mysql_close($con);
header("location: assa.php");
?>


